package com.bank.backend.boot.server.controller;

import com.bank.backend.boot.base.model.dto.BankOperationDTO;
import com.bank.backend.boot.base.model.vo.BankOperationVO;
import com.bank.backend.boot.server.annotation.ResponseResult;
import com.bank.backend.boot.server.service.BankOperationService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jiaowei
 * @since 2025/4/26 17:50
 */
@Slf4j
@Tag(name = "账户处理")
@RestController
@RequestMapping("/operation")
public class BankOperationController {
    @Resource
    private BankOperationService bankOperationService;

    @Operation(summary = "获取账户处理操作（分页）")
    @GetMapping("/queryOperationPage/{current}/{pageSize}")
    @ResponseResult
    public Page<BankOperationVO> queryOperationPage(@PathVariable("current") int current, @PathVariable("pageSize") int pageSize) {
        return bankOperationService.queryOperationPage(current, pageSize);
    }

    @Operation(summary = "保存账户处理操作")
    @PostMapping("/saveOperation")
    @ResponseResult
    public boolean saveOperation(@RequestBody BankOperationDTO bankOperationDTO) {
        log.warn("账户处理操作入参：{}", bankOperationDTO);
        return bankOperationService.saveOperation(bankOperationDTO);
    }

    @Operation(summary = "解除异常账户")
    @GetMapping("/relieveOperation/{id}")
    @ResponseResult
    public boolean relieveOperation(@PathVariable("id") Long id) {
        log.warn("账户处理操作入参：{}", id);
        return bankOperationService.relieveOperation(id);
    }

}
